package com.example.backspring.Service.impl;

import com.example.backspring.config.GetUUID;
import com.example.backspring.config.Message;
import com.example.backspring.dao.BookMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class BookServiceImpl {
    @Resource
    BookMapper bookMapper;

    public Message addBook(String name, String author, double price) {
        String id= GetUUID.generateShortUuid();
        int res = bookMapper.addOneBook(id,name, author, price);
        Message result = new Message();
        if (res == 1) {
            System.out.println("添加成功");
            result.setMessage("添加成功");
            result.setSuccess(true);
            result.setStatus(1);
        } else {
            System.out.println("添加失败");
            result.setMessage("添加失败");
            result.setSuccess(false);
            result.setStatus(0);
        }
        return result;
    }

    ;
}
